package com.sun.springboot_mq.topic.sender;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author shkstart
 * @create 2021-10-24 20:34
 */
@Component
public class TopicSender {
    @Autowired
    private RabbitTemplate rabbitmqTemplate;
    public void send1(){
        String context = "hi, i am message 1";
        System.out.println("Sender : " + context);
        this.rabbitmqTemplate.convertAndSend("exchange","topic.message",context);
    }
    public void send2() {
        String context = "hi, i am messages 2";
        System.out.println("Sender : " + context);
        this.rabbitmqTemplate.convertAndSend("exchange", "topic.messages", context);
    }
}
